<?php
use_helper('I18N');
?>
<div class="breadcrumbs" id="breadcrumbs">
    <script type="text/javascript">
        try {
            ace.settings.check('breadcrumbs', 'fixed')
        } catch(e) {
        }

        $(function($) {
            $('.sparkline').each(function(){
                var $box = $(this).closest('.infobox');
                var barColor = !$box.hasClass('infobox-dark') ? $box.css('color') : '#FFF';
                $(this).sparkline('html', {tagValuesAttribute:'data-values', type: 'bar', barColor: barColor , chartRangeMin:$(this).data('min') || 0} );
            });

            $(".activeMember").click(function(event){
                event.preventDefault();
                var memberId = $(this).attr("ref");

                var answer = confirm("<?php echo __('Are you sure you want to activate this member?')?>");
                if (answer == true) {
                    waiting();

                    $("#doAction").val("ACTIVE");
                    $("#memberId").val(memberId);

                    $("#memberForm").submit();
                }
            });
            $(".deleteMember").click(function(event){
                event.preventDefault();
                var memberId = $(this).attr("ref");

                var answer = confirm("<?php echo __('Are you sure you want to delete this member?')?>");
                if (answer == true) {
                    waiting();

                    $("#doAction").val("DELETE");
                    $("#memberId").val(memberId);

                    $("#memberForm").submit();
                }
            });
        });
    </script>
    <form method="post" id="memberForm" action="/member/activateMember">
        <input type="hidden" id="doAction" name="doAction">
        <input type="hidden" id="memberId" name="memberId">
    </form>

    <ul class="breadcrumb">
        <li>
            <i class="icon-home home-icon"></i>
            <a href="/member/summary"><?php echo __('Home')?></a>
        </li>
        <li class="active"><?php echo __('Dashboard')?></li>
    </ul>
    <!-- .breadcrumb -->

    <div class="nav-search" id="nav-search">
        <form class="form-search">
            <span class="input-icon">
                <input type="text" placeholder="Search ..." class="nav-search-input"
                       id="nav-search-input" autocomplete="off"/>
                <i class="icon-search nav-search-icon"></i>
            </span>
        </form>
    </div>
    <!-- #nav-search -->
</div>

<div class="page-content">
<div class="page-header">
    <h1>
        <?php echo __('Home')?>
        <small>
            <i class="icon-double-angle-right"></i>
            <?php echo __('Dashboard')?>
        </small>
    </h1>
</div>
<!-- /.page-header -->

<div class="row">
<div class="col-xs-12">
<!-- PAGE CONTENT BEGINS -->

<?php include_component('component', 'alert', array('param' => $sf_user->getAttribute(Globals::SESSION_DISTID, 0))) ?>

<div class="row">
<div class="space-6"></div>

<div class="col-sm-7 infobox-container">
    <div class="infobox infobox-green  ">
        <div class="infobox-icon">
            <i class="icon-comments"></i>
        </div>

        <div class="infobox-data">
            <span class="infobox-data-number"><?php echo __('Last Login')?></span>

            <div class="infobox-content"><?php echo $lastLogin;?></div>
        </div>
        <!--<div class="stat stat-success">0%</div>-->
    </div>

    <div class="infobox infobox-blue  ">
        <div class="infobox-icon">
            <i class="icon-twitter"></i>
        </div>

        <div class="infobox-data">
            <span class="infobox-data-number"><?php echo count($pendingDistributors); ?></span>

            <div class="infobox-content"><?php echo __('pending members')?></div>
        </div>

        <!--<div class="badge badge-success">
            +32%
            <i class="icon-arrow-up"></i>
        </div>-->
    </div>

    <div class="infobox infobox-orange2  ">
        <div class="infobox-chart">
            <span class="sparkline" data-values="196,128,202,177,154,94,100,170,224"></span>
        </div>

        <div class="infobox-data">
            <span class="infobox-data-number"><?php echo $totalNetworks ?></span>

            <div class="infobox-content"><?php echo __('networks')?></div>
        </div>

        <!--<div class="badge badge-success">
            7.2%
            <i class="icon-arrow-up"></i>
        </div>-->
    </div>

    <div class="space-6"></div>


    <!--<div class="infobox infobox-blue infobox-small infobox-dark">
        <div class="infobox-chart">
            <span class="sparkline" data-values="3,4,2,3,4,4,2,2"></span>
        </div>

        <div class="infobox-data">
            <div class="infobox-content">e-Point</div>
            <div class="infobox-content">$<?php /*echo number_format($epoint, 2)*/?></div>
        </div>
    </div>-->
    <div class="infobox infobox-green infobox-small infobox-dark">
        <div class="infobox-chart">
            <span class="sparkline" data-values="3,4,2,3,4,4,2,2"></span>
        </div>

        <div class="infobox-data">
            <div class="infobox-content"><?php echo __('e-Wallet')?></div>
            <div class="infobox-content">$<?php echo number_format($ecash, 2)?></div>
        </div>
    </div>

    <div class="infobox infobox-blue infobox-small infobox-dark">
        <div class="infobox-icon">
            <i class="	icon-credit-card "></i>
        </div>

        <div class="infobox-data">
            <div class="infobox-content"><?php echo __('Rank')?></div>
            <div class="infobox-content"><?php echo $ranking?></div>
        </div>
    </div>
</div>

<div class="vspace-sm"></div>

<!-- /span -->
</div>
<!-- /row -->

<div class="hr hr32 hr-dotted"></div>


<?php if ($mlmIb) { ?>
<div class="row">
<div class="col-sm-7">
    <div class="widget-box transparent">
        <div class="widget-header widget-header-flat">
            <h4 class="lighter">
                <i class="icon-star orange"></i>
                <?php echo __('Pending Member List')?>
            </h4>

            <div class="widget-toolbar">
                <a href="#" data-action="collapse">
                    <i class="icon-chevron-up"></i>
                </a>
            </div>
        </div>

        <div class="widget-body">
            <div class="widget-main no-padding">
                <table class="table table-bordered table-striped">
                    <thead class="thin-border-bottom">
                        <tr>
                            <th>
                                <i class="icon-caret-right blue"></i>
                                <?php echo __('User Name')?>
                            </th>

                            <th>
                                <i class="icon-caret-right blue"></i>
                                <?php echo __('Full Name')?>
                            </th>

                            <th>
                                <i class="icon-caret-right blue"></i>
                                <?php echo __('Package')?>
                            </th>

                            <th class="hidden-480">
                                <i class="icon-caret-right blue"></i>
                                <?php echo __('Action')?>
                            </th>
                        </tr>
                    </thead>

                    <tbody>
                    <?php foreach ($pendingDistributors as $pendingDistributor) { ?>
                        <tr>
                            <td>
                                <b class="green"><?php echo $pendingDistributor->getDistributorCode(); ?></b>
                            </td>

                            <td>
                                <?php echo $pendingDistributor->getFullName(); ?>
                            </td>

                            <td>
                                <?php
                                $packageName = "";

                                $packageDB = MlmPackagePeer::retrieveByPK($pendingDistributor->getRankId());
                                if ($packageDB) {
                                    $packageName = $packageDB->getPackageName();
                                }
                                echo $packageName; ?>
                            </td>

                            <td class="hidden-480">
                                <a href="#" ref="<?php echo $pendingDistributor->getDistributorId(); ?>" class="red deleteMember">
                                    <i class="icon-trash bigger-130"></i>
                                </a>
                                <a href="#" ref="<?php echo $pendingDistributor->getDistributorId(); ?>" class="green activeMember">
                                    <i class="icon-flag bigger-130"></i>
                                </a>
                            </td>
                        </tr>
                    <?php } ?>
                    </tbody>
                </table>
            </div><!-- /widget-main -->
        </div><!-- /widget-body -->
    </div>
<!-- /widget-box -->
</div>
<!-- /span -->
<!-- /span -->
</div>
<?php } ?>
<!-- /row -->

<!-- PAGE CONTENT ENDS -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</div><!-- /.page-content -->